(define variadic->binary-from-end 
  (lambda (operator binary-operator last-value)
    (letrec ((loop
              (lambda (s)
                (if (null? s)
                    last-value
                    (binary-operator (car s)
                                     (loop (cdr s)))))))
      (lambda s
        (loop s)))))

;(define variadic->binary-from-start 
;  (lambda (operator binary-operator)
;    (letrec ((loop
;              (lambda (s)
;                (if (null? s)
;                    (binary-operator)
;                    (if (null? (cdr s))
;                        (binary-operator (car s))
;                        (binary-operator (car s)
;                                         (loop (cdr s)))))))
;      (lambda s
;        (loop s)))))

(define variadic->binary-from-start
  (lambda (operator binary-operator)
    (letrec ((loop
              (lambda (s)
                (if (null? s)
                    (binary-operator)
                    (if (null? (cdr s))
                        (car s)
                        (loop (cons (binary-operator (car s)
                                                     (cadr s))
                                    (cddr s))))))))
      (lambda s
        (loop s)))))
                    
(define variadic->binary-in-gaps
  (lambda (operator binary-operator)
    (letrec ((loop
              (lambda (s)
                (if (null? s)
                    (binary-operator)
                    (if (null? (cdr s))
                        (binary-operator (car s))
                        (if (binary-operator (car s) (cadr s))
                            (if (null? (cddr s))
                                #t
                                (loop (cdr s)))
                            #f)))))) 
      (lambda s
        (loop s)))))

(define my/ /)
(define my< <)
(define my> >)
(define my= =)
(define my+ +)
(define my- -)
(define my* *)


(define bin+ 
  (lambda (x y)
    (my+ x y)))
(define bin- 
  (lambda (x y)
    (my- x y)))
(define bin* 
  (lambda (x y)
    (my* x y)))
(define bin/ 
  (lambda (x y)
    (my/ x y)))
(define bin< 
  (lambda (x y)
    (my< x y)))
(define bin= 
  (lambda (x y)
    (my= x y)))
(define bin> 
  (lambda (x y)
    (my> x y)))
(define < (variadic->binary-in-gaps < bin<))
(define = (variadic->binary-in-gaps = bin=))
(define > (variadic->binary-in-gaps > bin>))
(define + (variadic->binary-from-end + bin+ 0))
(define / (variadic->binary-from-start / bin/))
(define * (variadic->binary-from-end * bin* 1))
(define - (variadic->binary-from-start - bin-))
(and 
 (eq? (+ 1 2 3 4 5 6) 21)
 (eq? (+ 7 1 2 3 4 5 6) 28)
 (eq? (+) 0)
 (eq? (- 1 2 3 4 5 6) -19)
 (eq? (- 100 50 50 50) -50)
 (eq? (* 1 2 3 4) 24)
 (eq? (/ 256 2 2 2 2 2 2 2 2) 1)
 (equal? (/ 1 2 3) 1/6) 
 (eq? (< 1 2 3 4 5 6) #t)
 (eq? (< 1 2 3 4 5 6 7) #t)
 (eq? (< 1 2 3 4 5 6 5) #f)
 (eq? (= 1 2 3 4 5 6) #f)
 (eq? (= 1 1 1 1 1 1 7) #f)
 (eq? (= 4 4 4 4 5 4) #f)
 (eq? (= 4 4 4 4 4) #t)
 (eq? (> 6 5 4 3 2 1) #t)
 (eq? (> 7 6 5 4 3 2 1) #t)
 (eq? (> 7 6 5 4 3 3 1) #f)
)
;< (variadic), = (variadic), > (variadic), + (variadic), / (variadic), * (variadic), - (variadic),
